<template>
  <div id='goods-item' @click="clickItem">
    <img :src="goodsItem.image" alt="">
    <div class="goods-info">
      <p>{{goodsItem.title}}</p>
      <span class="price">{{'￥'+ goodsItem.price}}</span>
      <span>{{goodsItem.comment + '条评论'}}</span>
    </div>
  </div>

</template>

<script>
export default {
  name: 'GoodsListItem',

  props: {
    goodsItem: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  methods: {
    clickItem() {
      this.$router.push('/detail/' + this.goodsItem.id)
    }
  },

}
</script>

<style>
  #goods-item {
    padding-bottom: 40px;
    position: relative;
    width: 48%;
  }

  #goods-item img {
    width: 100%;
    border-radius: 5px;
  }


  .goods-info {
    position: absolute;
    font-size: 12px;
    bottom: 5px;
    left: 0;
    right: 0;
    overflow: hidden;
    text-align: center;
  }

  .goods-info p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    margin-bottom: 3px;

  }

  .goods-info .price {
    color: var(--color-high-text);
    /* margin-right: 20xp; */
    padding-right: 20px;

  }





</style>